<template>
  <div>
    <br />
    <a-button type="primary" @click="handleBatch">批量修改</a-button>
    <br />
    <br />
    <a-card>
      <a-table
        :pagination="false"
        :columns="columns"
        :data-source="tableData"
        :rowKey="
          (record, index) => {
            return record.opId;
          }
        "
        :row-selection="{
          selectedRowKeys: selectedRowKeys,
          onChange: onSelectChange,
        }"
      >
        <template slot="produceTime" slot-scope="text">
          <!-- {{ text | formatSeconds }} -->
        </template>
        <template slot="operAte" slot-scope="text, record, index">
          <!-- <a-popconfirm @confirm="() => onDelete(index)"> -->
          <!-- <a-button>编辑</a-button> -->
          <a @click="handleEdit(record)">编辑</a>
          <!-- </a-popconfirm> -->
        </template>
      </a-table>
      <YieldModal ref="modalForm" @ok="modalFormOk" />
    </a-card>
  </div>
</template>

<script>
import api from "@/api/apiServer";
import YieldModal from "./components/YieldModal.vue";
import { columns } from "./components/tabConfig";
import { tableMinxins } from "@/unit/mixins/tableMinxins";
export default {
  name: "index",
  mixins: [tableMinxins],
  components: { YieldModal },
  data() {
    return { columns };
  },
  computed: {
    macSN() {
      return this.$route.query.macSn;
    },
  },
  mounted() {
    this.getList();
  },
  methods: {
    async getList(arg) {
      this.queryParam.macSN = this.macSN;
      if (arg === 1) {
        this.pagination.current = 1;
      }
      var params = this.getQueryParams();
      const { data: res } = await api.AllProduce(params);
      this.tableData = res.rows;
    },
    handleBatch() {
      if (this.selectedRowKeys.length > 0) {
        this.handleEdit({}, this.selectedRowKeys);
      } else {
        this.$message.error("请选择需要修改的程序名");
      }
    },
    handleEdit(record, idList) {
      this.$refs.modalForm.modalEdit(record, idList);
    },
    onSelectChange(selectedRowKeys) {
      this.selectedRowKeys = selectedRowKeys;
    },
  },
};
</script>

<style scoped></style>
